<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%response.setHeader("Pragma","No-cache"); 
response.setHeader("Cache-Control","no-cache"); 
response.setDateHeader("Expires", 0); 
response.flushBuffer();%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test request</title>
<style type="text/css">
#nav { width:850px; height:500px; border: 1px solid #D4CD49; border-radius:5px;box-shadow:0 0 10px #0CC;  position:fixed;left:30%;top:30%;display:none;background-color:White }
#close{
	width:60px;height:20px; float:right;
}
</style>
<script type="text/javascript" src="<%=basePath%>js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
	$(function(){
		
		$("#mold").change(function(){
			var moldValue = $(this).val();
			var href = "<%=basePath%>getUrl.do";
			$.ajax({
				url:href,
				data:{request:moldValue},
				success:function(data){
					 var obj = eval('(' + data + ')');
					 var url ="<%=basePath%>"+obj.url;
					 var body = obj.body;
					 console.log(url);
					 $("#url").val(url);
					 $("#body").val(body);
				}
			});
		});
		
		$("#submit").click(function(){
			 var body = $("#body").val();
			var url=$("#url").val();
	 	  $.ajax({
				url:url,
				data:{body:body},
				success:function(data){
					if(data==0){
						alert("参数发送异常！")
					}else if(data==1){
						var href = "<%=basePath%>getPic.do?num="+Math.random();
						var img="<img class='img' src="+href+">";
						$("#nav").show();
						$("#nav").append(img); 
					}else if(data==2){
						var href = "<%=basePath%>getSVG.do?num="+Math.random();
						var ifram = "<iframe src='<%=basePath%>getSVGimg.do' width='800' height='380'></iframe>";
						$("#nav").show();
						$("#nav").append(ifram); 
					}else if(data==3){
						var href = "<%=basePath%>getSVG.do?num="+Math.random();
						var ifram = "<iframe src='<%=basePath%>getText.do' width='800' height='450' style='font-size:20px;'></iframe>";
						$("#nav").show();
						$("#nav").append(ifram); 
					}
				}
			});   
			return false;
		}); 
		
		$("#close").click(function(){
			$("#nav").children("img").remove(); 
			$("#nav").children("iframe").remove(); 
			$("#nav").hide();
		});
	});
</script>
</head>
<body Style="margin-left:100px;">
	<h3>Test Request</h3>
	<br/>
	<form action="" method="post" id="urlForm">
		<table style="line-height:30px;">
			<tr>
				<td>Request</td>
				<td>
					<select style="width:300px;" id="mold">
						<option value="---请选择---">--请选择--</option>
						<option value="WMS_getMap.url">WMS_getMap.url</option>
						<option value="WMS_getMap.xml">WMS_getMap.xml</option>
						<option value="WMS_getMap_OpenLayers.url">WMS_getMap_OpenLayers.url</option>
						<option value="WMS_getMap_SLD_BODY_LiteralMode-1.3.url">WMS_getMap_SLD_BODY_LiteralMode-1.3.url</option>
						<option value="WMS_getMap_SLD_BODY_LiteralMode.url">WMS_getMap_SLD_BODY_LiteralMode.url</option>
						<option value="WMS_getMap_SVG.url">WMS_getMap_SVG.url</option>
						<option value="WMS_getMap_SVG_Style.url">WMS_getMap_SVG_Style.url</option>
						<option value="WMS_featureInfo.url">WMS_featureInfo.url</option>
						<option value="WMS_getCapabilities.url">WMS_getCapabilities.url</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>Url</td>
				<td>
					<input type="text" value="" id="url" style="width:650px;"/>
				</td>
			</tr>
			<tr>
				<td>Body</td>
				<td>
					<textarea rows="25" cols="90" style="border-radius:5px;" id="body"></textarea>
				</td>
			</tr>
			<tr>
				<td>
					<input type="submit" value="SUBMIT" id="submit" style="border-radius:5px; height:30px;"/>
				</td>
				<td>
					<div id="nav">
						<div id="close"><img alt="close" src="<%=basePath%>images/close.png"></div>
					</div>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>